<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use common\components\Upload;
use common\models\shop\ShopGoods;
/* @var $this yii\web\View */
/* @var $model common\models\shop\ShopGoods */

$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Shop Goods', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
              <?= Html::a('返回','javascript:history.back(-1)'); ?>  <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">

                <div class="shop-goods-view">

                    <p>
                        <?= Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
                        <?= Html::a('删除', ['delete', 'id' => $model->id], [
                            'class' => 'btn btn-danger',
                            'data' => [
                                'confirm' => '您确定删除此项吗?',
                                'method' => 'post',
                            ],
                        ]) ?>
                    </p>

                    <?= DetailView::widget([
                        'model' => $model,
                        'template' => '<tr><th style="width:20%">{label}</th><td>{value}</td></tr>',
                        'attributes' => [
                            'id',
                            'cate.name',
                            'displayorder',
                            'title',
                            [
                                'attribute' => 'thumb',
                                'format' => 'raw',
                                'value' => function($model){
                                    return Html::img(Upload::checkGetUrl($model->thumb),['width'=>100]);
                                }
                            ],
                            [
                                'attribute' => 'mutithumb',
                                'format' => 'raw',
                                'value' => function($model){
                                    $mutithumb = Upload::checkGetUrl($model->mutithumb,true,'mutithumb');
                                    $html = '';
                                    foreach ($mutithumb as $key => $row){
                                        $html .= Html::img(Upload::checkGetUrl($row),['width'=>100,'style'=>'margin-right:10px;']);
                                    }
                                    return $html;
                                }
                            ],
                            'unit',
                            'goodssn',
                            'marketprice',
                            'productprice',
                            'costprice',
                            'originalprice',
                            'total',
                            'sales',
                            [
                                'attribute' => 'createtime',
                                'value' => function($model){
                                    return date('Y-m-d H:i:s',$model->createtime);
                                }
                            ],
                            'weight',
                            'maxbuy',
                            'usermaxbuy',
                            'dispatch',
                            [
                                'attribute' => 'isnew',
                                'value' => function($model){
                                    return ShopGoods::$isnew[$model->isnew];
                                }
                            ],
                            [
                                'attribute' => 'ishot',
                                'value' => function($model){
                                    return ShopGoods::$ishot[$model->ishot];
                                }
                            ],

                            [
                                'attribute' => 'isdiscount',
                                'value' => function($model){
                                    return ShopGoods::$isdiscount[$model->isdiscount];
                                }
                            ],

                            [
                                'attribute' => 'isrecommand',
                                'value' => function($model){
                                    return ShopGoods::$recommand[$model->isrecommand];
                                }
                            ],
                            [
                                'attribute' => 'istime',
                                'value' => function($model){
                                    return ShopGoods::$istime[$model->isrecommand];
                                }
                            ],
                            [
                                'attribute' => 'timestart',
                                'value' => function($model){
                                    return $model->timestart?date('Y-m-d H:i:s',$model->timestart):'';
                                }
                            ],
                            [
                                'attribute' => 'timeend',
                                'value' => function($model){
                                    return $model->timeend?date('Y-m-d H:i:s',$model->timeend):'';
                                }
                            ],
                            'viewcount',
                            [
                                'attribute' => 'status',
                                'value' => function($model){
                                    return ShopGoods::$statues[$model->status];
                                }
                            ],
                            [
                                'attribute' => 'description',
                                'format' => 'raw',
                            ],
                            [
                                'attribute' => 'content',
                                'format' => 'raw',
                            ],
                        ],
                    ]) ?>

                </div>
            </div>
        </div>
    </section>
</section>